//*************************************************************************************
//* 作    者： 
//* 创建时间： 2021-11-16 10:54:09
//*  描    述：

//* ************************************************************************************
using System;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;

public class TwinkleGraphicBehaviour : MonoBehaviour
{
    [SerializeField]
    private float m_startAlpha;
    [SerializeField]
    private float m_endAlpha;
    [SerializeField]
    private float m_duration;
    private float m_timer;
    private Graphic m_graphic;
    private Color m_color;

    private void Start()
    {
        m_graphic = GetComponent<Graphic>();
        if (!m_graphic || m_duration == 0)
            enabled = false;
        m_color = m_graphic.color;
    }

    void Update()
    {
        m_timer += Time.deltaTime;
        if (m_timer > m_duration)
        {
            m_timer = 0;
        }
        m_color.a = Mathf.Lerp(m_startAlpha, m_endAlpha, m_timer / m_duration);
        m_graphic.color = m_color;
    }
}
